<template>
	<z-paging ref="paging" :refresher-out-rate="0.8" :show-empty-view-reload-when-error="false"
		:empty-view-img-style="{ width: '308rpx', height: '308rpx' }"
		empty-view-error-img="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/12/1c53b8aed0c74201bb092265803a1d48.png"
		empty-view-img="https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/10/12/987eadb1d50949a0a7e25dbbd99abe30.png"
		empty-view-error-text="暂无数据" bg-color="#F9FAFC " v-model="dataList" @query="queryList">
		<view class="fund_details">
			<view class="fundList" v-for="(item, index) in dataList">
				<view class="flex_wrap row_between">
					<u-text :text="item.remark" size="28rpx" color="#3D3D3D" />
					<u-text :text="item.transactionType == 0 ? '+'+formatDecimal(
					                                    numDiv(
					                                        item.transactionAmount,
					                                        100
					                                    )
					                                ) : '-'+formatDecimal(
					                                    numDiv(
					                                        item.transactionAmount,
					                                        100
					                                    )
					                                )" size="28rpx"
						:color="item.transactionType == 0 ? '#18C195' : '#3D3D3D'" align="right" />
				</view>
				<u-text margin="14rpx 0 0" :text="item.createTime" size="24rpx" color="#777" />
			</view>
		</view>
	</z-paging>
</template>

<script>
	import {
		baseUrl
	} from "@/config/tendIdConfig";
	import {
		numDiv,
	} from "@/js_sdk/nl-precisionNum/precisionNum.js";
	import {
		formatDecimal
	} from "@/utils/index.js";
	export default {
		data() {
			return {
				dataList: [],
				numDiv, //除
				formatDecimal: formatDecimal,
				isCustomer:false,
				customerId:''
			};
		},
		onLoad(options) {
			this.isCustomer = options.isCustomer
			this.customerId = options.customerId
			console.log(options,'1111')
		},
		methods: {
			queryList(pageNum, pageSize) {
				const token = this.$store.getters?.customer_token || uni.getStorageSync("customer_token")
				const that = this
				if(that.isCustomer){
					uni.request({
						url: baseUrl + "/customer/balance_log/listBalanceLogByCustomerId",
						method: "POST",
						header: {
							Authorization: token
						},
						data: {
							pageNum: pageNum,
							pageSize: pageSize,
							customerId:that.customerId
						},
						success(res) {
							const dataList = res.data.data.rows ?? []
							that.$refs.paging.complete(dataList)
						}
					})
				}else{
					uni.request({
						url: baseUrl + "/customer/balance_log/listBalanceLog",
						method: "POST",
						header: {
							Authorization: token
						},
						data: {
							pageNum: pageNum,
							pageSize: pageSize,
						},
						success(res) {
							const dataList = res.data.data.rows ?? []
							that.$refs.paging.complete(dataList)
						}
					})
				}
			},
		}
	};
</script>

<style lang="scss" scoped>
	.fund_details {
		width: 100%;
		background: #FFFFFF;
		padding: 0 28rpx 28rpx;
	}

	.fundList {
		border-bottom: 1rpx solid #D8D8D8;
		padding: 28rpx 0;
	}
</style>